﻿using System;
using NCommet.Core.Agents;
using System.Web.Security;
using System.Web;
using System.Threading;
using System.Security.Principal;

namespace NCommet.Modules.AspNetWhoAmI
{
    public class AspNetWhoAmI : IWhoAmI
    {
        #region IWhoAmI Members

        public IPrincipal GetCurrentUser()
        {
            return (HttpContext.Current != null) ? HttpContext.Current.User : Thread.CurrentPrincipal;
        }

        public string[] GetRolesOfUser(string username)
        {
            return Roles.GetRolesForUser(username);
        }

        public string[] GetAvailableRoles()
        {
            return Roles.GetAllRoles();
        }

        #endregion
    }
}
